﻿<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="FIM_ExpenseRateEmps.aspx.cs" Inherits="KPIS.GERP.GFMS.APP.App_UI.Forms.FIM_ExpenseRateEmps" Trace="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="../CssClass.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="../Scripts/Common.js" type="text/jscript"></script>
    <script language="JavaScript" src="../Scripts/DatePicker.js" type="text/jscript"></script>
</head>
<body>
    <form id="form1" runat="server" style="font-family: 'ms sans Serif'; font-size: x-small;" >
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
        
        //======================== ExpRate ===========================
            //var sumExpRateAmount = null;
            var sumBathAmount = null;
            //var tempSumAmount = 0.0;
            var tempSumBathAmount = 0.0;

            function FooterLoad1(sender, args)
            {
                sumBathAmount = sender;
            }
            
            function txtBlur(tExpRateAmount, tDay, tHour, tMinute, tAmount, tAmountMin, tAmountMax)
            {
                var txtExpRateAmount = $find(tExpRateAmount);
                var txtDay = $find(tDay);
                var txtHour = $find(tHour);
                var txtMinute = $find(tMinute);
                var txtAmount = $find(tAmount);
                var txtAmountMin = document.getElementById(tAmountMin);
                var txtAmountMax = document.getElementById(tAmountMax);

                var dExpRateAmount = 0;
                var dDay = 1;
                var dHour = 1;
                var dMinute = 1;
                var dAmount = 0;
                var dAmountMin = 0;
                var dAmountMax = 0;
                
                if (txtExpRateAmount.get_value().toString().length > 0)
                    dExpRateAmount = txtExpRateAmount.get_value();
                    
                if (txtAmountMin.value.length > 0)
                    dAmountMin = txtAmountMin.value;
                    
                if (txtAmountMax.value.length > 0)
                    dAmountMax = txtAmountMax.value;
                    
                if (dExpRateAmount > dAmountMax)
                {
                    txtExpRateAmount.set_value(dAmountMax);
                    dExpRateAmount = dAmountMax;
                }
                    
                if (txtDay != null)
                {
                    if (txtDay.get_value().toString().length > 0)
                        dDay = txtDay.get_value();
                }

                if (txtHour != null)
                {
                    if (txtHour.get_value().toString().length > 0)
                        dHour = txtHour.get_value();
                }

                if (txtMinute != null)
                {
                    if (txtMinute.get_value().toString().length > 0)
                        dMinute = txtMinute.get_value();
                }
                
                dAmount = dExpRateAmount * dDay * dHour * dMinute;
                txtAmount.set_value(dAmount);
                sumBathAmount.set_value(tempSumBathAmount + dAmount);
            }
            
            function txtFocus(tExpRateAmount, tDay, tHour, tMinute, tAmount, tAmountMin, tAmountMax)
            {
                var txtAmount = $find(tAmount);
                var dAmount = 0;
                
                if (txtAmount.get_value().toString().length > 0)
                    dAmount = txtAmount.get_value();
                    
                tempSumBathAmount = sumBathAmount.get_value() - dAmount;
            }
            
            function GetRadWindow()
            {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
            
            function returnToParent(tSumAmount, tAmount, tExchangeRate, tBathAmount, tGrpAmount)
            {
                var oArg = new Object();
                var oWnd = GetRadWindow();
                
                var txtSumAmount = $find(tSumAmount);
                
                oArg.amount = txtSumAmount.get_value();
                oArg.tAmount = tAmount;
                oArg.tExchangeRate = tExchangeRate;
                oArg.tBathAmount = tBathAmount;
                oArg.tGrpAmount = tGrpAmount;
                
                oWnd.close(oArg);
            }
            
        //============================================================
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Panel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Panel1" 
                        LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
    </telerik:RadAjaxLoadingPanel>
    
    <asp:Panel ID="Panel1" runat="server">
        <telerik:RadTextBox ID="txtBgmExpSeq" runat="server" Width="0px" BorderWidth="0px" />
        <telerik:RadTextBox ID="txtBgmSourceSeq" runat="server" Width="0px" BorderWidth="0px" />
        <telerik:RadGrid GroupingSettings-CaseSensitive="false" ID="grdFimExpenseRate" runat="server" AutoGenerateColumns="false"
            AllowMultiRowEdit="false" AllowMultiRowSelection="true" AllowFilteringByColumn="false"
            Width="900px" Height="450px" AllowPaging="false"
            GroupingSettings-GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;"
            GroupingSettings-GroupContinuedFormatString=""
            GroupingSettings-GroupContinuesFormatString=""
            GroupingSettings-GroupSplitFormat=""
            OnItemDataBound="grdFimExpenseRate_ItemDataBound">
            <MasterTableView AllowMultiColumnSorting="True" CellSpacing="-1" GroupLoadMode="Client"
                DataKeyNames="emp_seq" NoMasterRecordsText="< ไม่มีข้อมูล >" GroupsDefaultExpanded="true">
                <RowIndicatorColumn>
                    <HeaderStyle Width="10px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="10px" />
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="emp_seq" UniqueName="emp_seq" Visible="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="bgm_exp_seq" UniqueName="bgm_exp_seq" Visible="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="class_seq" UniqueName="class_seq" Visible="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="old_class_seq" UniqueName="old_class_seq" Visible="False">
                    </telerik:GridBoundColumn>
                    
                    <%--<telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="25px" HeaderButtonType="None" HeaderText="เลือก">
                        <HeaderStyle Width="25px" />
                    </telerik:GridClientSelectColumn>--%>
                    <telerik:GridBoundColumn DataField="traveler_name" HeaderText="ชื่อผู้เดินทาง"
                        UniqueName="traveler_name" FilterControlWidth="100%" AutoPostBackOnFilter="true"
                        CurrentFilterFunction="Contains" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>
                    <%--<telerik:GridBoundColumn DataField="pos_name" HeaderText="ตำแหน่ง"
                        UniqueName="pos_name" FilterControlWidth="100%" AutoPostBackOnFilter="true"
                        CurrentFilterFunction="Contains" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="job_site_name" HeaderText="สังกัด"
                        UniqueName="job_site_name" FilterControlWidth="100%" AutoPostBackOnFilter="true"
                        CurrentFilterFunction="Contains" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>--%>
                    <telerik:GridBoundColumn DataField="class_name" HeaderText="ระดับปัจจุบัน"
                        UniqueName="class_name" FilterControlWidth="100%" AutoPostBackOnFilter="true"
                        CurrentFilterFunction="Contains" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>
                    <%--<telerik:GridBoundColumn DataField="old_class_name" HeaderText="ระดับ(C)"
                        UniqueName="old_class_name" FilterControlWidth="100%" AutoPostBackOnFilter="true"
                        CurrentFilterFunction="Contains" ShowFilterIcon="False">
                    </telerik:GridBoundColumn>--%>
                    <telerik:GridTemplateColumn UniqueName="emp_rate_seq" HeaderText="ประเภทอัตราค่าใช้จ่าย" HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <telerik:RadComboBox ID="ddlExpRateSeq" runat="server"
                                DataTextField="exp_rate_name" DataValueField="exp_rate_seq"
                                Filter="Contains" AutoPostBack="True" Width="190px"
                                OnSelectedIndexChanged="ddlExpRateSeq_SelectedIndexChanged">
                            </telerik:RadComboBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn UniqueName="quantity" HeaderText="อัตราต่อหน่วย" HeaderStyle-Width="200px">
                        <ItemTemplate>
                            <%--<telerik:RadNumericTextBox ID="txtAmountMin" runat="server" Width="0px"
                                CssClass="NumericTextBox" NumberFormat-DecimalDigits="2">
                            </telerik:RadNumericTextBox>
                            <telerik:RadNumericTextBox ID="txtAmountMax" runat="server" Width="0px"
                                CssClass="NumericTextBox" NumberFormat-DecimalDigits="2">
                            </telerik:RadNumericTextBox>--%>
                            <input id="hAmountMin" runat="server" type="hidden" />
                            <input id="hAmountMax" runat="server" type="hidden" />
                            <telerik:RadNumericTextBox ID="txtExpRateAmount" runat="server" Width="100px"
                                CssClass="NumericTextBox" NumberFormat-DecimalDigits="2">
                            </telerik:RadNumericTextBox>&nbsp;ต่อ&nbsp;
                            <telerik:RadNumericTextBox ID="txtDay" runat="server" Width="40px" CssClass="NumericTextBox" Visible="false">
                            </telerik:RadNumericTextBox>
                            <asp:Label ID="lblDay" runat="server" Text=" วัน" Visible="false" />
                            <telerik:RadNumericTextBox ID="txtHour" runat="server" Width="40px" CssClass="NumericTextBox" Visible="false">
                            </telerik:RadNumericTextBox>
                            <asp:Label ID="lblHour" runat="server" Text=" ชั่วโมง" Visible="false" />
                            <telerik:RadNumericTextBox ID="txtMinute" runat="server" Width="40px" CssClass="NumericTextBox" Visible="false">
                            </telerik:RadNumericTextBox>
                            <asp:Label ID="lblMinute" runat="server" Text=" นาที" Visible="false" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="จำนวนเงิน" UniqueName="amount" HeaderStyle-Width="110px">
                        <ItemTemplate>
                            <telerik:RadNumericTextBox ID="txtAmount" runat="server" Width="100px"
                                CssClass="NumericTextBox" ReadOnly="true" NumberFormat-DecimalDigits="2" />
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" 
                GroupContinuedFormatString="" GroupContinuesFormatString="" 
                GroupSplitFormat="" />
            <ClientSettings EnableRowHoverStyle="True">
                <Selecting AllowRowSelect="false" />
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
            </ClientSettings>
        </telerik:RadGrid>
        <table width="900px">
            <tr>
                <td width="100px">
                    <asp:LinkButton ID="cmdOK" runat="server" CssClass="LinkButtonBig">
                        <img alt="" id="imgOK" runat="server" src="~/App_UI/Images/Buttons/Update.gif" /> ตกลง
                    </asp:LinkButton>
                </td>
                <td width="150px">
                    <asp:Label ID="lblError" runat="server" ForeColor="Red" Visible="false" />
                </td>
                <td align="right" width="500px">
                    รวมทั้งหมด :
                </td>
                <td align="right">
                    <telerik:RadNumericTextBox ID="txtSumBathAmount" runat="server" ReadOnly="true" 
                        ForeColor="Blue" Width="100px" CssClass="NumericTextBox" >
                        <ClientEvents OnLoad="FooterLoad1" />
                    </telerik:RadNumericTextBox>
                </td>
                <td>
                    บาท
                </td>
            </tr>
        </table>
    </asp:Panel>
    
    </form>
</body>
</html>
